I download and install the last vesrion of MongoDb which is 4.0.2 and i set the correct path variable.
When i want to start the mondoDb service using mongod
command i got the following error:
exception in initAndListen: NonExistentPath: Data directory C:\data\db\ not found., terminating
i know that i should create the directory missing, but that directory is automatically created in the following path: C:\Program Files\MongoDB\Server\4.0
I checked the mongod.cfg file and the correct path is already set : dbPath: C:\Program Files\MongoDB\Server\4.0\data
Now how to tell the mongo to look for the folder he thinks is missing in the correct path ?
Daniel Gabor :
I had the same issue but after I create the directory C:\\data\\db\\ it just worked.",
2018-10-04T13:35:37
Raja Sekar :
I too had the same issue after an Windows update, Mongodb did not start automatically. Creating a new directory C:data/db will not be the right way as Mongodb has already configured the directory C:\\Program Files\\MongoDB\\Server\\4.0\\data as datapath.\n\nRun the following command in cmd as Administrator.\n\ncd C:\\Program Files\\MongoDB\\Server\\4.0\\bin\nmongod --dbpath=\"C:\\Program Files\\MongoDB\\Server\\4.0\\data\".\n\n\nThis worked for me.",
2019-04-09T04:06:25
haidar :
i tried to open CMD in admin mode and the error was gone. Hope this helps someone.",
2019-11-04T06:22:04
shesha reddy :
got to C:\\Program Files\\MongoDB\\Server\\4.0\\bin\\mongod.cfg file\nupdate below fields with these values\ndbPath: ....\\data\\db (directory path)\nand restart server once",
2020-12-09T14:21:32
Vishal Bramhankar :
\nCreate the directory/folder like below -\nC:\\data\\db\n\nopen cmd at C:\\Program Files\\MongoDB\\Server\\6.0\\bin and run 'mongod' command like below -\nC:\\Program Files\\MongoDB\\Server\\6.0\\bin>mongod\n\n\nproblem solved!",
2022-12-03T08:40:02